﻿@using KRM.Core
@model List<tblKRMWOutboundCentre>
@if (ViewBag.SelectedStatusId == (int)WOutboundCentreStatus.Pending)
{
<form class="col-md-12" id="frmRequest-content" action="/OutboundCentre/DeleteList" method="POST">
    <table class="table table-striped table-bordered table-hover dataTable dataTable-customsort  dataTable-noscroll" >
        <thead>
            <tr>
                <th class="nosort" style="padding-left:2px;padding-right:2px"><button class="btn btn-sm red" type="submit">Decline</button></th>
                <th>Product</th>
                <th>Site</th>
                <th>Price Found</th>
                <th>Price Location</th>
                <th class="sort-desc">Time Attempted</th>
                <th class="nosort">Customer's Name</th>
                <th class="nosort">Customer's Email</th>
                <th class="nosort">Customer's Telephone</th>
                <th class="nosort">Callback Complete?</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item   in Model)
            {
                var statusClass = "";
                switch (item.StatusId) 
                {
                    case (int)WOutboundCentreStatus.Pending:
                        statusClass = "info";
                        break;
                    case (int)WOutboundCentreStatus.Completed:
                        statusClass = "success";
                        break;
                    case (int)WOutboundCentreStatus.Declined:
                        statusClass = "danger";
                        break;
                }
                <tr class="@statusClass" >
                    <td style="text-align: center ;vertical-align: middle;">
                        <input type="checkbox" name="lstDelete" value="@item.Id"/>
                    </td>
                    <td style="text-align: center ;vertical-align: middle;">
                        <a target="blank" href="@item.PmStoreDomain/Product.aspx?prodID=@item.PmProductId">
                            <img style="border: 0; width: 100px;" src="@item.PmStoreDomain/images/products/@item.PmProductImage">
                            <br>@item.PmProductName - @item.PmOptionName
                        </a>
                    </td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.Site)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.PmPriceFound)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.PmPriceLocation)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.RequestDate)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.CustomerName)</td>
                    <td style="text-align: center ;vertical-align: middle;">
                        <a href="mailto:@item.EmailAddress" title="@item.EmailAddress">Email Customer</a>
                    </td>
                    <td style="text-align: center ;vertical-align: middle;">@item.Telephone1<br>@item.Telephone2</td>
                    <td style="text-align: center ;vertical-align: middle;padding:2px">
                        <div style="width: 190px">
                        @if (item.StatusId == (int)WOutboundCentreStatus.Pending)
                        {
                            <p>
                                @Html.DropDownList("ActionId", new SelectList(ViewBag.ActionList, "Id", "Name",@item.ActionId??0),new {@class="form-control",@Id="cbbActionId"+item.Id})  
                            </p>
                            <p>
                                <button type="button" class="btn red  btn-sm"  onclick="DeleteRequest(@item.Id)" aria-hidden="true">Decline</button>
                                <button type="button" class="btn btn-sm green" onclick="CompleteRequest(@item.Id,$('#cbbActionId@(item.Id)').val(),'@item.EmailAddress')"aria-hidden="true">Completed</button>
                            </p>
                        }
                        </div>
                    </td>
                </tr>
            }
        </tbody>
    </table>
</form>
}
else if (ViewBag.SelectedStatusId == (int)WOutboundCentreStatus.Completed)
{
    <table class="table table-striped table-bordered table-hover dataTable dataTable-customsort  dataTable-noscroll" >
        <thead>
            <tr>
                <th>Product</th>
                <th>Site</th>
                <th>Price Found</th>
                <th>Price Location</th>
                <th class="sort-desc">Time Attempted</th>
                <th class="nosort">Customer's Name</th>
                <th class="nosort">Customer's Email</th>
                <th class="nosort">Customer's Telephone</th>
                <th>Date Completed</th>
                <th class="nosort">Action</th>
                <th class="nosort">Completed By</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item   in Model)
            {
                var statusClass = "";
                switch (item.StatusId) 
                {
                    case (int)WOutboundCentreStatus.Pending:
                        statusClass = "info";
                        break;
                    case (int)WOutboundCentreStatus.Completed:
                        statusClass = "success";
                        break;
                    case (int)WOutboundCentreStatus.Declined:
                        statusClass = "danger";
                        break;
                }
                <tr class="@statusClass" >
                    <td style="text-align: center ;vertical-align: middle;">
                        <a target="blank" href="@item.PmStoreDomain/Product.aspx?prodID=@item.PmProductId">
                            <img style="border: 0; width: 100px;" src="@item.PmStoreDomain/images/products/@item.PmProductImage">
                            <br>@item.PmProductName - @item.PmOptionName
                        </a>
                    </td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.Site)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.PmPriceFound)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.PmPriceLocation)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.RequestDate)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.CustomerName)</td>
                    <td style="text-align: center ;vertical-align: middle;">
                        <a href="mailto:@item.EmailAddress" title="@item.EmailAddress">Email Customer</a>
                    </td>
                    <td style="text-align: center ;vertical-align: middle;">@item.Telephone1<br>@item.Telephone2</td>
                    <td style="text-align: center ;vertical-align: middle;">@item.DateApproved
                    </td>
                    <td style="text-align: center ;vertical-align: middle;">@item.tblKRMWOutboundCentreAction.Name
                    @if(item.ActionId==11){
                            <p>
                                Reason: @item.OtherComment
                            </p>
                    }
                    </td>
                    <td style="text-align: center ;vertical-align: middle;">@item.UserApproved.Username
                </tr>
            }
        </tbody>
    </table>
}
else if (ViewBag.SelectedStatusId == (int)WOutboundCentreStatus.Declined)
{
<div class="col-md-12" id="ListRequest-content">
    <table class="table table-striped table-bordered table-hover dataTable dataTable-customsort  dataTable-noscroll" >
        <thead>
            <tr>
                <th>Product</th>
                <th>Site</th>
                <th>Price Found</th>
                <th>Price Location</th>
                <th class="sort-desc">Time Attempted</th>
                <th class="nosort">Customer's Name</th>
                <th class="nosort">Customer's Email</th>
                <th class="nosort">Customer's Telephone</th>
                <th>Date Declined</th>
                <th class="nosort">Declined By</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item   in Model)
            {
                var statusClass = "";
                switch (item.StatusId) 
                {
                    case (int)WOutboundCentreStatus.Pending:
                        statusClass = "info";
                        break;
                    case (int)WOutboundCentreStatus.Completed:
                        statusClass = "success";
                        break;
                    case (int)WOutboundCentreStatus.Declined:
                        statusClass = "danger";
                        break;
                }
                <tr class="@statusClass" >
                                    <td style="text-align: center ;vertical-align: middle;">
                        <a target="blank" href="@item.PmStoreDomain/Product.aspx?prodID=@item.PmProductId">
                            <img style="border: 0; width: 100px;" src="@item.PmStoreDomain/images/products/@item.PmProductImage">
                            <br>@item.PmProductName - @item.PmOptionName
                        </a>
                    </td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.Site)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.PmPriceFound)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.PmPriceLocation)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.RequestDate)</td>
                    <td style="text-align: center ;vertical-align: middle;">@(item.CustomerName)</td>
                    <td style="text-align: center ;vertical-align: middle;">
                        <a href="mailto:@item.EmailAddress" title="@item.EmailAddress">Email Customer</a>
                    </td>
                    <td style="text-align: center ;vertical-align: middle;">@item.Telephone1<br>@item.Telephone2</td>
                                        <td style="text-align: center ;vertical-align: middle;">@item.DateApproved
                    </td>
                    <td style="text-align: center ;vertical-align: middle;">@item.UserApproved.Username
                </tr>
            }
        </tbody>
    </table>
</div>
}

